package com.jxb.visibility.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Schedul {
    public static void main(String[] args) {
        ScheduledThreadPoolExecutor executor = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(5);
//        executor.schedule();
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("123");
            }
        };
//        executor.scheduleWithFixedDelay(runnable, 0, 1, TimeUnit.SECONDS);
        executor.scheduleAtFixedRate(runnable, 0, 1, TimeUnit.SECONDS);
    }
}
